package cn.z2huo.knowledge.basic.bit.hashmap;

/**
 * <p>
 *
 * @author z2huo
 */
class HashMapTableSizeForTest {

    public static void main(String[] args) {

        System.out.println(tableSizeFor(0));
        System.out.println(tableSizeFor(1));
        System.out.println(tableSizeFor(2));
        System.out.println(tableSizeFor(3));
        System.out.println(tableSizeFor(6));
        System.out.println(tableSizeFor(8));

    }

    private static int tableSizeFor(int cap) {
        int n = -1 >>> Integer.numberOfLeadingZeros(cap - 1);
        return (n < 0) ? 1 : n + 1;
    }

}
